/**
 * udes.ds.rmi
 * Constant.java
 * 3 sept. 08
 */
package ift605.tp3.utils.equations;

import java.math.BigDecimal;

/**
 * Stores a fix value for x or y
 * 
 * @author Luc Bergevin
 * @version 1.0
 */
public class VariableEq extends AbstractEq implements ISimpleEquation, IUnaireEquation
{
    
    private static final long serialVersionUID = 1L;
    private final double _value;
    
    public VariableEq(double value)
    {
        super();
        _value = value;
    }
    
    public double getValue()
    {
        return _value;
    }
    
    /**
     * @see udes.ds.IEquation.hw.Equation#getFunctionValue(double)
     */
    public double getFunctionValue(double x)
    {
        return _value * x;
    }
    
    /**
     * @see AbstractEq.ds.rmi.hw.AbstractEquation#getUserReadableString()
     */
    @Override
    public String getUserReadableString()
    {
        return Double.toString(_value) + "x";
    }
    
    @Override
    public double getX()
    {
        return getValue();
    }
    
    @Override
    public double getY()
    {
        return Double.NaN;
    }
    
    @Override
    public BigDecimal eval(BigDecimal x)
    {
        return BigDecimal.valueOf(_value).multiply(x);
    }
    
}
